using UnityEngine;
using System.Collections;

public class DoorDestroy : MonoBehaviour {

	private float i =1;
	public float amount;
    public bool notDestroy;

	void Start()
	{
        if(renderer.material.shader != Shader.Find("Transparent/Diffuse"))
		renderer.material.shader = Shader.Find("Transparent/Diffuse");
	}
	
	void Update () 
	{
		i -= (amount*Time.deltaTime);
		renderer.material.color = new Color(renderer.material.color.r,renderer.material.color.g,renderer.material.color.b,i);
		
		if(i <= 0)
		{
            if(!notDestroy)
			Destroy(gameObject);

            if (notDestroy)
            {
                Destroy(this);
            }
		}

	}
}
